home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 12.4 KB | 401 lines | [TEXT/MPS ] |
- // UMailable.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UMAILABLE__
- #define __UMAILABLE__
-
- #if qPowerTalk
-
- // MacApp
-
- #ifndef __MACAPPTYPES__
- #include "MacAppTypes.h"
- #endif
-
- #ifndef __UCLASSDESC__
- #include "UClassDesc.h"
- #endif
-
- #ifndef __UCOMMAND__
- #include "UCommand.h"
- #endif
-
- // Toolbox
-
- #ifndef __APPLEEVENTS__
- #include <AppleEvents.h>
- #endif
-
- #ifndef __OCE__
- #include <OCE.h>
- #endif
-
- #ifndef __OCEAUTHDIR__
- #include <OCEAuthDir.h>
- #endif
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class CAEDesc;
- class MScriptableObject;
- class TAppleEvent;
- class TDocument;
- class TLetter;
- class TToolboxEvent;
-
- // For decodeing phone number info stored in DSSpecs
- struct PhoneNumberInfo
- {
- short fSubType;
- CStr31 fCountryCode;
- CStr31 fAreaCode;
- CStr31 fPhoneNumber;
- CStr31 fPostFix;
- CStr255 fDirectDial;
- };
-
- //----------------------------------------------------------------------------------------
- // CDSSpec represents an AOCE DSSpec structure. DSSpecs are used to represent most objects
- // in AOCE including Catalogs, Catalog nodes, Catalog records, and mail addresses.
- // The DSSpec data is usually resides in a packed format, the PackedDSSpec. However, in
- // order to do much with it, the data needs to be unpacked into several other AOCE structures.
- // CDSSpec keeps the data packed in fPackedDSSpec but handles unpacking it when needed.
- // Only when the data is unpacked are the other CDSSpec fields valid. Unless you change the data
- // you don't need to pack it again when you are done.
- // CDSSpec owns the packed data in its fPackedDSSpec pointer. It will make a copy of the data
- // you pass its constructor and will dispose of its copy when deleted.
- //----------------------------------------------------------------------------------------
-
- class CDSSpec
- {
- public:
-
- PackedDSSpecPtr fPackedDSSpec;
- DSSpec fDSSpec;
- RecordID fRecordID;
- RLI fRLI;
- Boolean fUnpacked;
-
- CDSSpec();
- // Initializes a CDSSpec.
-
- CDSSpec(PackedDSSpecPtr aPackedDSSpec);
- // Initializes a CDSSpec using a PackedDSSpecPtr. A copy of the data is made and unpacked.
-
- CDSSpec(const CAEDesc& anAEDesc);
- // Initializes a CDSSpec using a CAEDesc. A copy of the data is made and unpacked.
-
- ~CDSSpec();
- // Disposes of the data in fPackedDSSpec.
-
- Boolean Unpack();
- // Unpacked the data in fPackedDSSpec into the fDSSpec, fRecordID, and fRLI fields.
-
- void Pack();
- // Takes whatever is in the fDSSpec, fRecordID, and fRLI fields and packs it into a new fPackedDSSpec.
-
- void GetPathName(CStr255& thePathName);
- // If the DSSpec describes a catalog record, returns a path name to that record.
-
- void GetAEDesc(CAEDesc& theAEDesc);
- // Puts a copy of the fPackedDSSpec data into an CAEDesc.
-
- // Handy conversions.
-
- inline StringPtr GetRecordName(){ return OCERToPString(this->fRecordID.local.recordName); };
-
- inline StringPtr GetDirectoryName(){ return OCERToPString((RStringPtr)this->fRLI.directoryName); };
-
- inline StringPtr GetRecordType(){ return OCERToPString(this->fRecordID.local.recordType); };
-
- OSType GetExtensionType();
-
- // Conversion from string to address formats.
- // Addresses are formatted: record name<service name><catalog name>address value.
- // The catalog name is omitted if the same as the directory name.
- // Some examples:
- // "Ken Ryall<AppleTalk>Ken's Mac@R&D Zone"
- // "Tom Becker<Internet>twb@apple.com"
- // "Janie Phillips<Pager><Century Paging>2568345"
- // "Tom's Fax Machine<Fax Terminal>1-408-555-8989"
- // "Paul Drake<PowerShare>Sales:Staff:East Coast"
-
- static Boolean GetDirectoryExtensionType(OSType myExtType, Boolean& isRString,
- CStr255& dirSysName);
- // Look up the extension type in the directory extension type table ('dxtt' resource).
-
- void AddressToString(CStr255& theString);
- // Creates a string that describes this DSSpec.
-
- void StringToAddress(CStr255& theString);
- // Parses a valid address string into a DSSpec.
-
- // Utilities for parsing address strings
-
- void ParsePowerShareAddress(CStr31& dsDirName,
- CStr255& dsExtValue);
- // Parses a path name to a catalog record and sets the fRLI to point to it.
-
- void ParseAppleTalkAddress(CStr255& dsExtValue);
- // Parses the extension string into an AppleTalk EntityName.
-
- void ParseDirectDialupAddress(CStr255& dsExtValue);
- // Parses a phone number string into a packed direct dial number.
-
- void ParseFaxSTFAddress(CStr31& dsRecName,
- CStr255& dsExtValue);
- // Parses a phone number string into a format for the STF fax PMSAM.
-
- void ParseRStringAddress(CStr255& dsExtValue);
- // The default MSAM address format is an RString in the extensionValue.
-
- // Utilities for unpacking phone number info
-
- PhoneNumberInfo* UnpackDirectDialupInfo();
-
- PhoneNumberInfo* UnpackSTFFaxInfo();
-
- // Utilities for packing and unpacking strings
-
- static void PackString(Ptr& packIn,
- const CStr31& theStr);
-
- static void PackRString(Ptr& packIn,
- const CStr31& theStr);
-
- static void PackRString(Ptr& packIn,
- RStringPtr theStr);
-
- static StringPtr UnpackRString(Ptr& unpackFrom);
- };
-
- //----------------------------------------------------------------------------------------
- // CCatalogs represents the top level of the catalog system. It will enumerate
- // through each catalog (AppleTalk, PowerShare, X.500, database etc) but not the
- // contents of the catalog.
- //----------------------------------------------------------------------------------------
-
- class CCatalogs
- {
- public:
-
- DirectoryName fStartingDirectoryName;
- DirDiscriminator fStartingDirDiscriminator;
- ForEachDirectory fForEachDirectoryProc;
- long fClientData;
- Boolean fCatalogFound;
- DirectoryNamePtr fDirectoryNameToFind;
- DirDiscriminator fFoundDirDiscriminator;
-
- CCatalogs();
-
- void EnumerateCatalogs(OCEDirectoryKind catalogType,
- ForEachDirectory actionProc);
- // Calls the actionProc for each catalog.
-
- Boolean FindCatalogByName(DirectoryNamePtr theCatalogName,
- OCEDirectoryKind catalogType,
- DirDiscriminator& discriminator);
- // Return TRUE if there is a catalog of the requested name and type.
-
- static Boolean FindCatalogByNameProc(long clientData,
- const DirectoryName* dirName,
- const DirDiscriminator* discriminator,
- DirGestalt features);
-
- static Boolean EachCatalogGlue(long clientData,
- const DirectoryName* dirName,
- const DirDiscriminator* discriminator,
- DirGestalt features);
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // MMailing: Adds mailing capability to an application.
- //----------------------------------------------------------------------------------------
-
- class MMailing
- {
- MA_DECLARE_CLASS;
-
- public:
-
- OSType fMainLetterFileType; // principal file type this application
- // uses for letters.
-
- MMailing();
- // Constructor
-
- virtual OSErr GetAOCEIdentity(AuthIdentity& theIdentity,
- Boolean allowInteraction);
- // Get the local AOCE identity
-
- virtual Boolean DoMailerEvent(TToolboxEvent* event);
- // Passes events to the standard mail package. Returns true if the SMP handled the event.
-
- virtual void OpenOldLetters(CommandNumber itsOpenCommand,
- const CAEDesc& letterList);
- // Similar to OpenOld but handles a list of letter specs from the mail system.
-
- virtual TDocument* FindLetter(Handle itsSpec);
- // Given a handle to a LetterSpecifier, if that letter is already opened, returns the TDocument.
- // Otherwise returns NULL.
-
- virtual Boolean CanOpenLetter(CommandNumber itsCommandNumber,
- Handle itsSpec);
- // Given a handle to a LetterSpecifier returns if you want to open this letter.
- // Default return TRUE.
-
- virtual Boolean IsLetterFileType(OSType theFileType);
- // Return true if theFileType is a letter format this application can open.
-
- virtual void DoOpenNextLetter(CommandNumber aCommandNumber);
- // Open the next unread letter in the mailbox.
-
- // Data type conversion routines.
-
- virtual OSErr TextToDSSpec(const void *textPtr, Size textSize, CAEDesc &result);
-
- virtual OSErr DSSpecToText(const void *dataPtr, Size dataSize, CAEDesc &result);
-
- // Glue routines
-
- static pascal OSErr TextToDSSpecGlue(DescType typeCode, const void *dataPtr, Size dataSize, DescType toType, long handlerRefcon, AEDesc *result);
-
- static pascal OSErr DSSpecToTextGlue(DescType typeCode, const void *dataPtr, Size dataSize, DescType toType, long handlerRefcon, AEDesc *result);
- };
-
- //----------------------------------------------------------------------------------------
- // MMailable: Corresponds to a Finder document. Manages mail data in files and in main
- // memory.
- //----------------------------------------------------------------------------------------
-
- class MMailable
- {
- MA_DECLARE_CLASS;
-
- public:
- TLetter* fLetter; // The mailer enclosing this document.
-
- OSType fMailCreator; // Creator ID to use for letters. Defaults to AppleMail.
-
- OSType fMailType; // Type ID to use for letters. Defaults to fMainLetterFileType.
-
- unsigned long fSendFormats; // Actually an SMPSendFormatMask
-
-
- MMailable();
- // Constructor
-
- virtual ~MMailable();
- // Destructor.
-
-
- virtual void AddNativeMailContent(Boolean& okToSend);
- // Called to put the document's content into the letter in the document's
- // native format. Default glues to the letter's equivalent function.
-
- virtual void AddSnapshotMailContent(Boolean& okToSend);
- // Called to create a snapshot of the document and add this to the letter.
- // Default glues to the letter's equivalent function.
-
- virtual void AddStandardMailContent(Boolean& okToSend);
- // Called to put the document's content into the letter in the standard mail
- // format. Default glues to the letter's equivalent function.
-
- long CountContainedMailers();
-
- void DoAECreateMailer(TAppleEvent* message,
- TAppleEvent* reply);
- // Adds a mailer to this document.
-
- virtual void DoAECreateReply(TAppleEvent* message,
- TAppleEvent* reply);
- // Glue to the letter's function.
-
- void DoAESend(TAppleEvent* message,
- TAppleEvent* reply);
- // Handles the send event
-
- virtual Boolean DoMailMenuCommand(CommandNumber aCommandNumber);
- // Handles the default menu commands associated with a mailable document.
-
- virtual void DoMakeLetter();
- // Create the enclosing letter object. Override to make more capable letters.
-
- virtual void DoSetupMailMenus();
- // Set up the mail menu.
-
- virtual TDocument* FindLetter(Handle itsSpec);
- // True is this letter is already open.
-
- MScriptableObject* GetIndContainedMailer(long index);
-
- virtual unsigned long GetSendFormats();
- // Returns the sending formats this document supports. Default returns
- // fSendFormats, which is initialized to all three.
-
- virtual Boolean HasMailer();
- // Does this document have a mailer attached?
-
- virtual void ImageDocumentForLetter(Boolean inColor);
- // Create an image of this document to be used as a letter snapshot.
-
- void LetterContentChanged();
- // Tells the SMP that the document contents have changed. Called from
- // TDocument::Changed.
-
- virtual void MakeRoomForMailer(long amount, Boolean redraw);
- // Adjust the views to make room for the mailer
-
- virtual void OpenLetter();
- // Glue to the letter's function.
-
- virtual void ReadLetter(Boolean forPrinting);
- // Glue to the letter's function.
-
- virtual Boolean ReadNativeMailContent();
- // Called from OpenLetter to read the content in the document's native format.
- // Default glues to the letter's function.
-
- virtual Boolean ReadStandardMailContent();
- // Called from OpenLetter to read the content in StandardMail Format.
-
- virtual Boolean ReadSnapshotMailContent();
- // Called from OpenLetter to read the content in Snapshot Format.
-
- virtual void SetReplyContents(TDocument* replyToDoc);
- // Called when this document is being created in reply to another. Override this
- // to create any initial contents from the document being replied to.
- };
-
- //----------------------------------------------------------------------------------------
- // TOpenNextLetterCommand: Open the next letter
- //----------------------------------------------------------------------------------------
-
- class TOpenNextLetterCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
-
- TOpenNextLetterCommand();
-
- virtual ~TOpenNextLetterCommand();
-
- void IOpenNextLetterCommand(CommandNumber itsCommandNumber);
-
- virtual void DoIt();
-
- virtual TAppleEvent* MakeAppleEvent();
- };
-
- extern MMailing* gMailing;
-
- #endif // qPowerTalk
-
- #endif // __UMAILABLE__
-